// pages/withdraw/withdraw.js
const app = getApp()
const util = require('../../utils/util.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
          num:1,
          listb: [],//待审核"
          title: "兑换列表",//当前页面的标题
          listc: [],//代付款
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
          this.setData({
                  headerheight: app.globalData.navHeight
          })
          this.request()
  },
        login: function () {
                var that = this
                wx.login({
                        success: function (res) {
                                var code = res.code
                                var data = {
                                        userCode: code,
                                        userImageUrl: "",
                                        userName: ""
                                }
                                util.promotion(app.globalData.appurl + "/qinqiang/user", "POST", data, that.succeed)
                        }
                })
        },
        succeed: function (res) {
                wx.setStorageSync('tekon', res.data.token)
                wx.setStorageSync('userInfo', res.data.user)
                this.request()
        },
        request: function () {
                wx.showNavigationBarLoading()
                wx.showLoading({
                        title: '玩命加载中...',
                })
                var data = {
                        user_id: wx.getStorageSync('userInfo').id
                }
                var header = {
                        'authorization': wx.getStorageSync('tekon'),
                        'content-type': "application/x-www-form-urlencoded"
                }
                //提现记录
                util.formhttp(app.globalData.appurl +"/goldconins/pay-history", 'get', data, header, this.stat);
        },
        stat: function (res) {
                console.log(res)
                if (res.status == 401) {
                        this.login()
                }
                wx:wx.hideNavigationBarLoading()
                wx:wx.hideLoading()
                var listb = this.data.listb
                var listc = this.data.listc
                for (var item in res.data.list) {
                        if (res.data.list[item].status=="待审核"){
                                listb.push(res.data.list[item])
                        }
                        if (res.data.list[item].status == "待付款") {
                                listc.push(res.data.list[item])
                        }
                }
                this.setData({
                        list: res.data.list,
                        listb: listb,
                        listc: listc
                })
        },
        kefu:function(){
                console.log(123)
                this.setData({
                        kefushow:true
                })
        },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
tebnum:function(e){
        this.setData({
                num:e.currentTarget.dataset.mun
        })
}
})